<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
    <meta name="author" content="Coderthemes">

    <link rel="stylesheet" href="/adminstatic/base/base.css"/>
    <script src="/adminstatic/base/baseCss.js"></script>

    <style type="text/css">
        html, body {
            background: #fff;
        }

        .layui-input-block {
            margin-left: 0;
        }
    </style>
</head>

<body class="fixed-left">

<!-- Begin page -->
<div id="wrapper" style="overflow: auto;">

    <div class="container">

        <div class="panel panel-default" style="box-shadow: none">
            <div class="panel-body">
                <form class="layui-form" action="">
                    <div id="inputForm" class="form-horizontal">
                        <div class="row" style="padding:0 20px">
                            <div class="form-group">
                                <div class="col-md-12" >
                                    <div class="col-xs-6 col-md-4">
                                        <div class="layui-form-item">
                                            <div class="layui-input-block">
                                                <label> <small class="notNullFlag">*</small>部门:</label>
                                                <label>
                                                    <select id="positionType" name="positionType" lay-verify="required"
                                                            lay-filter="positionType">
                                                        <option value="研发类">研发类</option>
                                                        <option value="销售类">销售类</option>
                                                        <option value="服务类">服务类</option>
                                                        <option value="供应链类">供应链类</option>
                                                        <option value="财经类">财经类</option>
                                                        <option value="法务类">法务类</option>
                                                        <option value="人力资源">人力资源</option>
                                                    </select>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6 col-md-4">
                                        <div class="layui-form-item">
                                            <div class="layui-input-block">
                                                <label><small class="notNullFlag">*</small>城市:</label>
                                                <label>
                                                    <select id="city" name="city" lay-verify="required"
                                                            lay-filter="city">
                                                        <option value="广州市">广州市</option>
                                                        <option value="佛山市">佛山市</option>
                                                    </select>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6 col-md-4">
                                        <div class="layui-form-item">
                                            <div class="layui-input-block">
                                                <label><small class="notNullFlag">*</small>类型:</label>
                                                <label>
                                                    <select id="type" name="type" lay-verify="required"
                                                            lay-filter="type">
                                                        <option value="校招">校招</option>
                                                        <option value="社招">社招</option>
                                                    </select>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>


                        <div class="form-group">
                            <div class="col-md-12">
                                <label for="name"><small class="notNullFlag">*</small> 职位名称</label>
                                <input class="form-control" type="text" id="name" name="name"
                                       value="" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-12 ">
                                <label for="name"><small class="notNullFlag">*</small> 工作职责</label>
                                <textarea id="editor" name="editor" style="width:100%;height:500px;"></textarea>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div id="actions">
                <button type="button" class="layui-btn layui-btn-normal" id="submitBtn">保存</button>
                <button type="button" class="layui-btn layui-btn-primary" onclick="closeIframe()">取消</button>
            </div>
        </div><!-- panel-body -->
    </div> <!-- panel -->

</div> <!-- container -->

</div>
<!-- END wrapper -->

<script src="/adminstatic/base/base.js"></script>
<script type="text/javascript">
    ckeditor();

    var positionType;//职位类别
    var city;//城市
    var type;//招聘类型
    var form;
    layui.use('form', function () {
        form = layui.form;
        positionType =$("#positionType option:selected").val();
        city =$("#city option:selected").val();
        type =$("#type option:selected").val();
        form.on('select(positionType)', function (data) {
            //1:拿到select对象：
            positionType = $("#positionType option:selected").val();
        });

        form.on('select(city)', function (data) {
            city =$("#city option:selected").val();
            console.log(city)
        })
        form.on('select(type)', function (data) {
            type =$("#type option:selected").val();
        })
    });


    $("#submitBtn").click(function () {
        var name = $("input[name='name']").val();
        var content = CKEDITOR.instances.editor.getData();
        console.log(name,positionType,city,type);
        if (!vaildeParam(name)) {
            layer.msg("职位名称不能为空", {icon: 5});
            return;
        }
        if (!vaildeParam(content)) {
            layer.msg("工作职责不能为空", {icon: 5});
            return;
        }

        var api = '/admin/recruitment/addRecruitment';
        var data = {
            "name": name,
            "positionType": positionType,
            "city": city,
            "type": type,
            "content": content,
        }

        postJSON(api, data, function (res) {
            cleanSuccess(res)
        })

    })
</script>
</body>
</html>